/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import java.util.Collection;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
/**
 *
 * @author Administrador			
 */
@Entity
@Table(name = "stock")
@NamedQueries({
    @NamedQuery(name = "Stock.findAll", query = "SELECT s FROM Stock s"),
    @NamedQuery(name = "Stock.findByPharmacyIdByUserId", query = "SELECT s FROM Stock s WHERE s.userpharmacy.userpharmacyPK.pharmacyId = :pharmacyId AND s.userpharmacy.userpharmacyPK.userId = :userId"),
    @NamedQuery(name = "Stock.findByUserId", query = "SELECT s FROM Stock s WHERE s.userpharmacy.userpharmacyPK.userId = :userId"),
    @NamedQuery(name = "Stock.findByPharmacyId", query = "SELECT s FROM Stock s WHERE s.userpharmacy.userpharmacyPK.pharmacyId = :pharmacyId"),
    @NamedQuery(name = "Stock.findByStockId", query = "SELECT s FROM Stock s WHERE s.stockId = :stockId"),
    @NamedQuery(name = "Stock.findByName", query = "SELECT s FROM Stock s WHERE s.name = :name"),
    @NamedQuery(name = "Stock.findByAddress", query = "SELECT s FROM Stock s WHERE s.address = :address"),
    /*@NamedQuery(name = "Userprovider.deleteByStockIdByPharmacyId", query = "DELETE FROM Stock s WHERE s.stockId = :stockId AND s.userpharmacy.userpharmacyPK.pharmacyId = :pharmacyId"), */
    @NamedQuery(name = "Stock.findByPhone", query = "SELECT s FROM Stock s WHERE s.phone = :phone"),
    @NamedQuery(name = "Stock.findByRemark", query = "SELECT s FROM Stock s WHERE s.remark = :remark")})
public class Stock implements Serializable {
    private static final long serialVersionUID = 1L;
    /*
    @Id
    @Basic(optional = false)
    @Column(name = "stockId")*/
    @Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer stockId;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @Column(name = "address")
    private String address;
    @Column(name = "phone")
    private String phone;
    @Column(name = "remark")
    private String remark;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "stock")
    private Collection<Pharmacystock> pharmacystockCollection;
    @JoinColumns({
        @JoinColumn(name = "pharmacyId", referencedColumnName = "pharmacyId"),
        @JoinColumn(name = "userId", referencedColumnName = "userId")})
    @ManyToOne
    private Userpharmacy userpharmacy;
    @OneToMany(mappedBy = "stockId")
    private Collection<Transfer> transferCollection;
    @OneToMany(mappedBy = "stostockId")
    private Collection<Transfer> transferCollection1;
    @OneToMany(mappedBy = "stockId")
    private Collection<Item> itemCollection;

    public Stock() {
    }

    public Stock(Integer stockId) {
        this.stockId = stockId;
    }

    public Stock(Integer stockId, String name) {
        this.stockId = stockId;
        this.name = name;
    }

    public Integer getStockId() {
        return stockId;
    }

    public void setStockId(Integer stockId) {
        this.stockId = stockId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Collection<Pharmacystock> getPharmacystockCollection() {
        return pharmacystockCollection;
    }

    public void setPharmacystockCollection(Collection<Pharmacystock> pharmacystockCollection) {
        this.pharmacystockCollection = pharmacystockCollection;
    }

    public Userpharmacy getUserpharmacy() {
        return userpharmacy;
    }

    public void setUserpharmacy(Userpharmacy userpharmacy) {
        this.userpharmacy = userpharmacy;
    }

    public Collection<Transfer> getTransferCollection() {
        return transferCollection;
    }

    public void setTransferCollection(Collection<Transfer> transferCollection) {
        this.transferCollection = transferCollection;
    }

    public Collection<Transfer> getTransferCollection1() {
        return transferCollection1;
    }

    public void setTransferCollection1(Collection<Transfer> transferCollection1) {
        this.transferCollection1 = transferCollection1;
    }

    public Collection<Item> getItemCollection() {
        return itemCollection;
    }

    public void setItemCollection(Collection<Item> itemCollection) {
        this.itemCollection = itemCollection;
    }
    /*
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (stockId != null ? stockId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Stock)) {
            return false;
        }
        Stock other = (Stock) object;
        if ((this.stockId == null && other.stockId != null) || (this.stockId != null && !this.stockId.equals(other.stockId))) {
            return false;
        }
        return true;
    }

    @Override*/
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Stock[ stockId=" + stockId + " ]";
    }
    
}
